/*
 * Author: vyouzhi <vyouzhi@163.com>
 * http://www.xda.cn
 *
 * File: LIBEVENT_LIB_H
 * Create Date: 2011-09-22 09:29:25
 *
 */
#ifndef LIBEVENT_LIB_H_
#define LIBEVENT_LIB_H_

#include <event.h>

#include "queue.h"

#define BUFLEN 1024

struct bufferq {
	/* The buffer. 
	u_char *buf;*/
	char *buf;
	/* The length of buf. */
	int len;

	/* The offset into buf to start writing from. */
	int offset;
	
	/* For the linked list structure. */
	TAILQ_ENTRY(bufferq) entries;
};

struct client {
	/* Events. We need 2 event structures, one for read event
	 * notification and the other for writing. */
	struct event ev_read;
	struct event ev_write;

	/* This is the queue of data to be written to this client. As
	 * we can't call write(2) until libevent tells us the socket
	 * is ready for writing. */
	TAILQ_HEAD(, bufferq) writeq;
};

void on_read(int fd, short ev, void *arg);
void on_write(int fd, short ev, void *arg);
void on_accept(int fd, short ev, void *arg);
void Event_Init(void);
#endif /* LIBEVENT_LIB_H_ */
/* vim: set ts=4 sw=4: */

